package com.ovopark.organize.server.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ovopark.organize.server.mapper.FranchiseesRegistrationFieldSelectMapper;
import com.ovopark.organize.server.model.entity.FranchiseesRegistrationFieldSelect;
import com.ovopark.organize.server.service.FranchiseesRegistrationFieldSelectService;
import com.ovopark.organize.server.util.CommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FranchiseesRegistrationFieldSelectServiceImpl extends ServiceImpl<FranchiseesRegistrationFieldSelectMapper, FranchiseesRegistrationFieldSelect> implements FranchiseesRegistrationFieldSelectService {

    Logger logger = LoggerFactory.getLogger(FranchiseesRegistrationFieldSelectServiceImpl.class);

    @Override
  public    FranchiseesRegistrationFieldSelect saveOrUpdateFranchiseesRegistrationFieldSelect(FranchiseesRegistrationFieldSelect select){
        if(select.getId() !=null){
            baseMapper.updateById(select);
        }else{
            baseMapper.insert(select);
        }
        return select;
    }

    @Override
    public void deleteFranchiseesRegistrationFieldSelectByIds(List<Integer> ids) {
        if(ids !=null && ids.size() >0){
            baseMapper.deleteBatchIds(ids);
        }
    }

    @Override
    public void deleteFranchiseesRegistrationFieldSelectByFieldIds(List<Integer> fieldIds) {
        if(fieldIds !=null && fieldIds.size() >0){
            String fieldIdsList = CommonUtil.IntegerToStringSql(fieldIds);
            baseMapper.updateDeltedByFieldIds(fieldIdsList);
        }
    }

    @Override
    public List<FranchiseesRegistrationFieldSelect> getSelectByFieldId(Integer id) {
        if(id !=null){
            LambdaQueryWrapper<FranchiseesRegistrationFieldSelect> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(FranchiseesRegistrationFieldSelect::getFranchiseesRegistrationFieldId,id);
            return baseMapper.selectList(queryWrapper);
        }
        return null;
    }


}
